package com.buddies.lottery.data.api;

import com.buddies.lottery.data.bean.BankResponse;
import com.buddies.lottery.data.bean.PayRecord;
import com.buddies.lottery.data.bean.PayType;
import com.buddies.lottery.data.bean.User;
import com.buddies.lottery.data.bean.Wallet;
import com.buddies.lottery.data.bean.WithdrawRecord;
import com.buddies.lottery.data.resp.BalanceResponse;
import com.buddies.lottery.data.resp.CheckWalletPwdResponse;
import com.buddies.lottery.data.resp.LoginResponse;
import com.buddies.lottery.data.resp.PayResponse;
import com.buddies.lottery.data.resp.PayResultResponse;
import com.buddies.lottery.data.resp.WithdrawResponse;
import com.buddies.lottery.data.result.ApiResult;
import com.buddies.lottery.data.result.PageResult;

import io.reactivex.Observable;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

/**
 * Description:
 * Date: 2018/2/24
 * Author: xuliang
 */
public interface UserApi {

    /* 登录 */
    @FormUrlEncoded
    @POST("login")
    Observable<ApiResult<LoginResponse>> postLogin(@Field("user_id") String userId, @Field("password") String password);

    /* 注册 */
    @FormUrlEncoded
    @POST("register")
    Observable<ApiResult<LoginResponse>> postRegister(@Field("user_id") String userId, @Field("password") String password);

    /* 重置密码 */
    @FormUrlEncoded
    @POST("user/pwd/update")
    Observable<ApiResult<LoginResponse>> postUpdatePassword(@Field("old_password") String userId, @Field("new_password") String password);

    /* 重置资金密码 */
    @FormUrlEncoded
    @POST("user/wallet/pwd/update")
    Observable<ApiResult<Object>> postUpdateWalletPwd(@Field("old_password") String oldPassword, @Field("new_password") String newPassword);

    /* 更新提现银行卡 */
    @FormUrlEncoded
    @POST("user/bank/update")
    Observable<ApiResult<Object>> postUpdateBank(@Field("card_name") String cardName, @Field("card_no") String cardNo, @Field("card_user") String cardUser, @Field("pwd") String walletPwd);

    /* 获取用户信息 */
    @GET("user/info")
    Observable<ApiResult<User>> getUserInfo(@Query("id") long userId);

    /* 充值 */
    @FormUrlEncoded
    @POST("user/pay/post")
    Observable<ApiResult<PayResultResponse>> postPay(@Field("pay_type") String payType, @Field("money") String money);

    /* 获取提现信息 */
    @GET("user/withdraw/info")
    Observable<ApiResult<WithdrawResponse>> getWithdrawInfo();

    /* 绑定收款二维码 */
    @FormUrlEncoded
    @POST("user/withdraw/bind")
    Observable<ApiResult<Object>> postQrcode(@Field("qrcode") String qrcodeUrl);

    /* 获取余额 */
    @GET("user/balance")
    Observable<ApiResult<BalanceResponse>> getBalance();

    /* 获取充值二维码 */
    @GET("user/pay/qrcode")
    Observable<ApiResult<PayResponse>> getPayQrcode();

    /* 获取充值记录 */
    @GET("user/pay/record")
    Observable<ApiResult<PageResult<PayRecord>>> getPayRecord(@Query("pay_type") String payType, @Query("page") int page);

    /* 获取钱包信息 */
    @GET("user/wallet")
    Observable<ApiResult<Wallet>> getWallet();

    /* 校验资金密码 */
    @GET("user/wallet/pwd/check")
    Observable<ApiResult<CheckWalletPwdResponse>> checkWalletPwd(@Query("pwd") String pwd);

    /* 获取提现银行卡 */
    @GET("user/bank")
    Observable<ApiResult<BankResponse>> getBank();

    /* 提现 */
    @FormUrlEncoded
    @POST("user/withdraw/post")
    Observable<ApiResult<Wallet>> postWithdraw(@Field("money") int money, @Field("pwd") String pwd);

    /* 获取交易类型 */
    @GET("user/pay/type")
    Observable<ApiResult<PageResult<PayType>>> getPayTypeList();

    /* 获取提现记录 */
    @GET("user/withdraw/record")
    Observable<ApiResult<PageResult<WithdrawRecord>>> getWithdrawRecord(@Query("page") int page);

    /* 注册下级 */
    @FormUrlEncoded
    @POST("agent/register")
    Observable<ApiResult<LoginResponse>> postAgentRegister(@Field("user_type") int userType, @Field("user_id") String userId, @Field("password") String password, @Field("rebate") float rebate);
}
